package com.xb.sourest.base;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;

import com.gyf.immersionbar.ImmersionBar;
import com.xb.sourest.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * 懒加载
 */
public  abstract  class BaseLazyFragment extends BaseFragment{



    protected View view;
    protected  Unbinder unbinder;
    public TextView title;
    public ImageButton top_back_btn;
    public Button top_right_sure_btn;
    public ImageButton top_right_more_btn;

    protected abstract  void loadData();
    protected abstract  void upView();

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (null != view) {
            ViewGroup parent = (ViewGroup) view.getParent();
            if (null != parent) {
                parent.removeView(view);
            }
            Log.e("fragment","-----");
        } else {
            view=inflater.inflate(initLayoutRes(), container, false);
        }
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        unbinder = ButterKnife.bind(this, view);
        Log.e("fragment","-----111");
        loadData();
        title = view.findViewById(R.id.top_title_text_view);
        top_back_btn = view.findViewById(R.id.top_back_btn);
        top_right_sure_btn = view.findViewById(R.id.top_right_sure_btn);
        top_right_more_btn = view.findViewById(R.id.top_right_more_btn);
        upView();
    }




    @Override
    public void onDestroy() {
        super.onDestroy();
        unbinder.unbind();
    }
}
